# 随机生成20个[1, 20]的正整数，统计每个数字出现的次数，排序并降序输出次数最多的前三个数字及次数
import random


random_nums = [random.randint(1,20) for i in range(20)]
print(random_nums)

d = {}
for i in random_nums:
    if i not in d:
        d[i] = 1
    else:
        d[i]+=1
        
print(sorted([(v,k) for k,v in d.items()], reverse=True)[0:3])
